﻿using System;
using Jin.Core.Query;
using System.Collections.Generic;
using Jin.Core.Schema;


namespace Jin.Core.DataProviders
{
    /// <summary>
    /// sql生成接口
    /// </summary>
    public interface ISqlGenerator
    {
        string ClientName { get; set; }

        SqlQuery Query { get; set; }
        /// <summary>
        ///sql片段驱动
        /// </summary>
        ISqlfragment sqlFragment { get; }

        /// <summary>
        /// 生成命令行
        /// </summary>
        /// <returns></returns>
        string GenerateCommandLine();
        /// <summary>
        /// 生成约束
        /// </summary>
        /// <returns></returns>
        string GenerateConstraints();
        /// <summary>
        /// 生成from列表
        /// </summary>
        /// <returns></returns>
        string GenerateFromList();
        /// <summary>
        /// 生成order by
        /// </summary>
        /// <returns></returns>
        string GenerateOrderBy();
        /// <summary>
        /// 生成 group by.
        /// </summary>
        /// <returns></returns>
        string GenerateGroupBy();

        /// <summary>
        /// 生成 joins.
        /// </summary>
        /// <returns></returns>
        string GenerateJoins();

        /// <summary>
        ///获取分页sql包装
        /// </summary>
        /// <returns></returns>
        string GetPagingSqlWrapper();

        /// <summary>
        /// 获取 select 字段.
        /// </summary>
        /// <returns></returns>
        List<string> GetSelectColumns();

        /// <summary>
        /// 查找字段列
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <returns></returns>
        IColumn FindColumn(string columnName);

        /// <summary>
        ///创建 select.
        /// </summary>
        /// <returns></returns>
        string BuildSelectStatement();

        /// <summary>
        ///创建 分页 select .
        /// </summary>
        /// <returns></returns>
        string BuildPagedSelectStatement();

        /// <summary>
        ///创建update .
        /// </summary>
        /// <returns></returns>
        string BuildUpdateStatement();

        /// <summary>
        /// 创建 insert.
        /// </summary>
        /// <returns></returns>
        string BuildInsertStatement();

        /// <summary>
        /// 创建 delete .
        /// </summary>
        /// <returns></returns>
        string BuildDeleteStatement();

        /// <summary>
        /// 设置 insert query.
        /// </summary>
        /// <param name="q">The q.</param>
        void SetInsertQuery(Insert q);
    }
}
